﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Windows.Forms;

namespace QuestLib_TestCode
{
    public class MyQuestPlayer : QuestLib.QuestPlayer
    {
        public uint _ID;

        Form1 _from;

        private uint _QuestID;

        public uint QuestID
        {
            get { return _QuestID; }
            set { _QuestID = value; }
        }

        private uint _ItemID;

        public uint ItemID
        {
            get { return _ItemID; }
            set { _ItemID = value; }
        }

        private uint _Money;

        public uint Money
        {
            get { return _Money; }
            set { _Money = value; }
        }

        //public uint _QuestID;
        //public uint _ItemID;


        //public override void OnEvent(QuestLib.EVENT eventID, IEnumerator<ICondition> gameEvent)
        //{
        //    quest._QuestPlayer = this;

        //    base.AddQuest(quest);


        //}

        public override string ToString()
        {
            return String.Format("Player {0}",_ID);
            
        }

        public MyQuestPlayer(uint ID,Form1 form)
        {
            _ID = ID;
            _from = form;
        }

        //SendNotify("뭐하나 어서 가져오게");

        public void Log(String msg)
        {
            _from.listBox1.Items.Add(String.Format("[{0}] call {1} ",_ID,msg));
        }


        public void Log(String msg, uint param)
        {
            _from.listBox1.Items.Add(String.Format("[{0}] call {1} [{2}]",_ID,msg,param));
        }

        public QuestLib.ICondition SendDialog(String msg)
        {

            Form2 form = new Form2(this, msg);

            form.Show();

            

            return new Conditon_Dialog();
        }




        public bool HasQuest(uint questID)
        {

            Log("HasQuest", questID);

            // 대충처리하고 

            return QuestID == questID;// new QuestLib.ICondition(QuestLib.EVENT.NONE, 0, 1);
        }

        public void GiveQuest(uint questID)
        {
            QuestID = questID;

            Log("GiveQuest", questID);
            // 대충처리하고 
            //return new QuestLib.ICondition(QuestLib.EVENT.NONE, 0,1);
        }


        public void GiveItem(uint itemID)
        {
            ItemID = itemID;
            Log("GiveQuest", itemID);
            // 대충처리하고 
            
        }


        public bool HasItem(uint itemID)
        {

            Log("HasItem", itemID);

            // 대충처리하고 

            return ItemID == itemID;// new QuestLib.ICondition(QuestLib.EVENT.NONE, 0, 1);
        }


        public void TakeItem(uint itemID)
        {


            if (_ItemID == itemID)
                _ItemID = 0;

            Log("TakeItem", itemID);
            // 대충처리하고 
            //return new QuestLib.ICondition(QuestLib.EVENT.NONE, 0, 1);
        }

        public void GiveMoney(uint money)
        {
            Money += money;
            Log("GiveMoney", money);
            // 대충처리하고 
            //return new QuestLib.ICondition(QuestLib.EVENT.NONE, 0, 1);
        }




    }
}
